using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class NewsletterSignup : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        UtilityManager util = new UtilityManager();
        DataSet ds = util.getStates();
        ddlState.DataSource = ds.Tables[0];
        ddlState.DataTextField = ds.Tables[0].Columns["State"].ColumnName.ToString();
        ddlState.DataValueField = ds.Tables[0].Columns["State"].ColumnName.ToString();
        ddlState.DataBind();
    }
    protected void btnSignUp_Click(object sender, EventArgs e)
    {
        ManagePerson manager = new ManagePerson();

        Person per = new Person();
        per.FirstName = txtFirstName.Text;
        per.LastName = txtLastName.Text;
        per.Address = txtAddress.Text;
        per.City = txtCity.Text;
        per.State = ddlState.SelectedValue;
        per.Zip = Convert.ToInt32(txtZip.Text);
        per.PhoneNumber = txtPhoneNumber.Text;
        per.Email = txtEmail.Text;
        per.LibraryID = Convert.ToInt32(Request.QueryString["id"]);

        manager.newsletterSignup(per);

        txtFirstName.Text = "";
        txtLastName.Text = "";
        txtAddress.Text = "";
        txtCity.Text = "";
        txtZip.Text = "";
        txtPhoneNumber.Text = "";
        txtEmail.Text = "";
        lblSuccess.Visible = true;
    }
}
